package ru.ognick.coachsystem.common;

import java.io.File;
import java.io.Serializable;

public class Exercise implements Serializable { 
	private static final long serialVersionUID = 4390405302880080415L;

	private boolean isActivity;
	private Time duration = new Time (14,88);
	private String name = "Отдых";
	private String description = "Описание";
	private boolean isBeep = true;
	private Time beepPeriod = new Time (7,40);
	private File mediaFile;
	
	
	public enum Field {
		isActivity,
		duration,
		name,
		description,
		isBeep,
		beepPeriod,
		mediaFile
	};
	
	@SuppressWarnings("unchecked")
	public <T>T getValue(Field field) {
		switch (field) {
		case isActivity:
			return (T) new Boolean(isActivity());
		case isBeep:
			return (T) new Boolean(isBeep());
		case duration:
			return (T) getDuration();
		case beepPeriod:
			return (T) getBeepPeriod();			
		case name:
			return (T) getName();			
		case description:
			return (T) getDescription();			
		case mediaFile:
			return (T) getMediaFile();
		default:
			return null;
		}
	}
	
	public <T> void setValue(Field field, T value) {
		switch (field) {
		case isActivity:
			setActivity((Boolean) value);
			break;
		case isBeep:
			setBeep((Boolean) value);
			break;
		case duration:
			setDuration((Time) value);
			break;
		case beepPeriod:
			setBeepPeriod((Time) value);
			break;			
		case name:
			setName((String) value);
			break;			
		case description:
			setDescription((String) value);
			break;						
		case mediaFile:
			setMediaFile((File) value);
			break;			
		default:
			break;
		}
	};
	
	
	public void setActivity(boolean isActivity) {
		this.isActivity = isActivity;
	}
	public boolean isActivity() {
		return isActivity;
	}
	
	public void setDuration(Time duration) {
		this.duration = duration;
	}
	public Time getDuration() {
		return duration;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	public String getDescription() {
		return description;
	}
	
	public void setBeepPeriod(Time beepPeriod) {
		this.beepPeriod = beepPeriod;
	}
	public Time getBeepPeriod() {
		return beepPeriod;
	}
	
	public void setMediaFile(File mediaFile) {
		this.mediaFile = mediaFile;
	}
	public File getMediaFile() {
		return mediaFile;
	}
	public void setBeep(boolean isBeep) {
		this.isBeep = isBeep;
	}
	public boolean isBeep() {
		return isBeep;
	}
}
